Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the page rotation when converting HTML to PDF, utilize the PageRotateAngle property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to PDF, you can set an HTML file as header and footer. Use the HtmlHeader and HtmlFooter properties within the BlinkConverterSettings class to do this.
You can download a complete working sample from GitHub.
Adjust the HTML margin top and bottom values according to the height of the HTML header and footer, as well as the margin settings.
The Blink rendering engine supports the injection of custom CSS to be applied to HTML or a URL before rendering it into a PDF document using the ‘Css’ property of the BlinkConverterSettings class
You can download a complete working sample from GitHub.
The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the ‘JavaScript’ property of the BlinkConverterSettings class.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the ‘ReuseBrowserProcess’ property of the HtmlToPdfConverter class.
You can download a complete working sample from GitHub.
The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder.
By default, HTML converter takes system temporary path (C:\Users<<username»\AppData\Local\Temp or C:\Windows\Temp) to perform the conversion.
The temporary path can be changed by using the TempPath property of BlinkConverterSettings. If this property is set, the converter uses the provided path to perform the conversion. Refer to the following code example.
You can download a complete working sample from GitHub.
When converting HTML to a PDF document, the default reference to the blink binaries path eliminates the need for manual addition. Nonetheless, if you prefer to manually add the blink binaries path or reference it from a custom location, simply set the path of the BlinkBinaries folder to the BlinkPath property of BlinkConverterSettings.
- The BlinkBinaries will be available in the HTMLConverter installed location ($SystemDrive\Program Files (x86)\Syncfusion\HTMLConverter\xx.x.x.xx\BlinkBinaries)
- The BlinkBinaries also available in NuGet package installed location if you are using Blink HTML converter from NuGet packages.
You can download a complete working sample from GitHub.
Resizing the HTML content within a PDF can be achieved through the utilization of the Scale property of Blink in HTML Converter.
The scaling factor should be within the range of 0.1 to 2.0.
You can download a complete working sample from GitHub.
HTML content being converted takes a long time to render or convert into a PDF can be achieved through the utilization of the Timeout property of Blink in HTML Converter.
You can download a complete working sample from GitHub.
The Blink HTML converter supports preserving tags from HTML to PDF using the EnableAccessibilityTags property in the BlinkConverterSettings class. Refer to the following code sample.
This support fully depends on the Chromium headless browser. Our converter preserves the tags, same as the saved PDF from Chrome.
You can download a complete working sample from GitHub.
The Blink HTML converter support adding the image background from HTML to Image using the ImageBackgroundColor property in BlinkConverterSettings class. Refer to the following code sample.
You can download a complete working sample from GitHub.
Converting HTML to PDF
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
|
Platforms
|
Assemblies
|
|
WinForms
WPF
ASP.NET
ASP.NET MVC
|
- Syncfusion.Compression.Base.dll
- Syncfusion.Pdf.Base.dll
- Syncfusion.HtmlConverter.Base.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
|
.NET/.NET Core
Blazor
|
- Syncfusion.Compression.Portable.dll
- Syncfusion.Pdf.Portable.dll
- Syncfusion.HtmlConverter.Portable.dll
- Newtonsoft.Json package (v13.0.1 or above)
|
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
HTML converter Features
To convert website URL or local HTML file to PDF document using Convert method in HtmlToPdfConverter class. refer to the following code example.
You can download a complete working sample from GitHub.
The HTML to PDF converter provides support for converting HTML string to PDF. While converting HTML string to PDF, converter provides option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the above image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location, then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to PDF using Convert method, refer to the following code example.
You can download a complete working sample from GitHub.
To convert website URL or local HTML file to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink rendering engine supports converting HTML string to Image. While converting HTML string to Image, converter provides an option to specify the base URL.
baseURL: Path of the resources (images, style sheets, scripts.,) used in the input HTML string.
For the following HTML string, the baseURL will be the path of the syncfusion_logo.gif image.
For example, if the previous image is in “C:/Temp/ HTMLFiles/syncfusion_logo.gif” location then the baseURL will be as follows.
baseURL: C:/Temp/HTMLFiles/
To convert the HTML string to Image using ConvertToImage method, refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports enabling or disabling the JavaScript using EnableJavaScript property in BlinkConverterSettings class. while converting HTML to PDF. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides an option to set the AdditionalDelay property while converting HTML to PDF. Additional delay is the waiting time of the converter for loading the external resources (styles, scripts, images and more). Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter support preserving URL links from HTML to PDF using EnableHyperLink property in BlinkConverterSettings class. Refer to the following code snippet.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating bookmarks automatically by enabling the EnableBookmarks property.
The bookmarks are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for creating a table of contents automatically by using the EnableToc property.
TOC are added from the <h> tag, it supports from <h1> to <h6>.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for customizing the table of contents style. Each header tag style can be customized by using HtmlToPdfTocStyle.
You can download a complete working sample from GitHub.
The Blink HTML Converter allows selection of media type while converting HTML to PDF. Blink rendering engine supports Screen and Print media types. Refer to the following code snippet to select Print MediaType.
You can download a complete working sample from GitHub.
Print MediaType MediaType enables the repeat html table header and footer support on every PDF page.
Blink rendering engine provides support for converting HTML forms to PDF fillable forms automatically by using the EnableForm property. To convert HTML form to PDF form, refer to the following code example.
You can download a complete working sample from GitHub.
The webpage you want to convert may protected with windows authentication. Blink rendering engine provides support for converting the Windows Authenticated webpage to PDF document by providing the Username and Password property in BlinkConverterSettings class. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter provides support for form authentication by using Cookies property in BlinkConverterSettings class. The cookies are send to web server for form authentication when the HTML page is requested. Each cookie is represented by a name and value. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports token-based authentication by using the HttpRequestHeaders property in BlinkConverterSettings class.. The token values will be send to web server when the HTML page is requested. Refer to the following code example.
You can download a complete working sample from GitHub.
The Blink HTML converter supports converting HTML to PDF in offline mode using EnableOfflineMode property in BlinkConverterSettings class. While converting HTML to PDF in offline mode, the converter does not access the resources from the internet. This may increase the performance in slow internet connection.
If an online URL is converted in offline mode, the converter will generate empty PDF as it will not try to load any resource from online.
You can download a complete working sample from GitHub.
HTTP GET and POST
The Blink HTML converter supports transmitting the parameter to the webpage. There are two methods to access a webpage. By default, Blink uses GET method. By using HTTP GET method, the parameters can be passed in the query string. In POST method, the parameters can be passed by using the HttpPostFields property.
Refer to the following code snippet to access a webpage using HTTP POST.
You can download a complete working sample from GitHub.
You can download a complete working sample from GitHub.
By default, the Blink rendering engine use system proxy settings for converting HTML to PDF. If proxy server is configured in the system, then the rendering engine automatically use the same settings for the conversion. Follow the below steps to set the system proxy settings:
- Control Panel > Network and Internet > Internet Options.
- From Internet properties window, open LAN settings under connections tab.
- Then, set proxy server address and port in LAN settings window.
You can specify the manual proxy settings for the conversion using the ProxySettings property. Refer to the following code snippet to configure the manual proxy settings for the conversion.
Adjusting the HTML content size in PDF is possible by using the ViewPortSize property of Blink HTML converter.
Refer to the following code snippet to adjust Blink viewport.
You can download a complete working sample from GitHub.
The Blink rendering engine provides support for converting only the part of an HTML document like a table, div, or image elements from the URL/HTML string. You can convert the particular HTML element using ConvertPartialHtml method by specifying the HTML element ID, refer to the following code example.
You can download a complete working sample from GitHub.
By using this SinglePageLayout property, you can render the whole HTML content into a single PDF page. The PDF page size is limited to 14400 points. There are two options to enable this feature since this is disabled by default.
Fit width option: Using this option, the HTML converter adjusts the PDF page height based on the HTML content height. PDF page width remains constant for this option.
Fit height option: Using this option, the HTML converter scale the HTML content and PDF page width to render the whole HTML content within the height. PDF page height remains constant for this option.
Getting height of the HTML content in PDF document is possible by using the PdfLayoutResult class. Using this result, you can add contents after converting HTML to PDF. Refer to the following code example.
Windows status can be used instead of additional delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoided by using WindowStatus property.
This feature requires changes in the HTML file.
If windows status does not match in code and HTML, then the converter will meet with deadlock.
You can download a complete working sample from GitHub.
To set the page size when converting HTML to PDF, utilize the PdfPageSize property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the margin when converting HTML to PDF, utilize the Margin property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the header and footer when converting HTML to PDF, utilize the PdfHeader and PdfFooter properties in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.
To set the Orientation when converting HTML to PDF, utilize the Orientation property in the BlinkConverterSettings class. Please refer to the following code example.
You can download a complete working sample from GitHub.